<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="//cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.js"></script>
    <link rel="stylesheet" href="../../index.css" />
    <title>Spine Phaser Example</title>
  </head>

  <body class="p-4 flex flex-col items-center">
    <h1>Mix and match</h1>
  </body>
  <script>
    const config = {
      type: Phaser.AUTO,
      width: 800,
      height: 600,
      type: Phaser.WEBGL,
      scene: {
        preload: preload,
        create: create,
        pack: {
          files: [
            {
              type: "scenePlugin",
              key: "spine.SpinePlugin",
              url: "../dist/iife/spine-phaser-v3.js",
              sceneKey: "spine",
            },
          ],
        },
      },
    };

    const game = new Phaser.Game(config);

    function preload() {
      this.load.spineBinary(
        "mix-and-match-data",
        "/assets/mix-and-match-pro.skel"
      );
      this.load.spineAtlas(
        "mix-and-match-atlas",
        "/assets/mix-and-match-pma.atlas"
      );
    }

    function create() {
      const mixAndMatch = this.add.spine(
        400,
        500,
        "mix-and-match-data",
        "mix-and-match-atlas",
        new spine.SkinsAndAnimationBoundsProvider(null, ["full-skins/girl"])
      );
      mixAndMatch.scale = 0.5;
      mixAndMatch.animationState.setAnimation(0, "walk", true);

      const skeletonData = mixAndMatch.skeleton.data;
      const skin = new spine.Skin("custom");
      skin.addSkin(skeletonData.findSkin("skin-base"));
      skin.addSkin(skeletonData.findSkin("nose/short"));
      skin.addSkin(skeletonData.findSkin("eyelids/girly"));
      skin.addSkin(skeletonData.findSkin("eyes/violet"));
      skin.addSkin(skeletonData.findSkin("hair/brown"));
      skin.addSkin(skeletonData.findSkin("clothes/hoodie-orange"));
      skin.addSkin(skeletonData.findSkin("legs/pants-jeans"));
      skin.addSkin(skeletonData.findSkin("accessories/bag"));
      skin.addSkin(skeletonData.findSkin("accessories/hat-red-yellow"));
      mixAndMatch.skeleton.setSkin(skin);
      mixAndMatch.skeleton.setToSetupPose();
    }
  </script>
</html>
